<template>
  <div id="app">
    <div id="container">
      <div id="header">
        <Menu mode="horizontal" theme="light">
          <div class="layout-logo">
            <img src="../assets/logo.png" />
          </div>
          <div class="login">
            <div v-if="show">
              <Button
                type="primary"
                shape="circle"
                icon="md-person"
                @click="reroute"
                >登录</Button
              >
            </div>
            <div v-else>
              <Button
                type="primary"
                shape="circle"
                icon="md-person"
                @click="jock"
                >{{ name }}</Button
              >
            </div>
          </div>
          <div class="menuitems">
            <MenuItem name="0" to="/" v-if="!manager">
              <Icon type="ios-paper" />
              主页
            </MenuItem>
            <MenuItem name="1" to="/panel" v-if="!manager">
              <Icon type="ios-paper" />
              仓库管理
            </MenuItem>
            <Submenu  name="2">
              <template slot="title">
                <Icon type="ios-stats" />
                员工管理
              </template>
              <MenuItem name="2-1" to="/staffIM" v-if="!manager">
                <Icon type="ios-people" />
                临时员工
              </MenuItem>
              <MenuItem name="2-2" to="/formal" v-if="!manager">
              <Icon type="ios-people" />
                正式员工
              </MenuItem>
            </Submenu>

            <MenuItem name="3" to="/sale" v-if="!manager">销售管理</MenuItem>
            <Submenu name="4" v-if="!manager">
              <template slot="title">
                <Icon type="ios-stats" />
                统计分析
              </template>
              <MenuGroup title="辅助决策">
                <MenuItem name="4-0" to="/data">质量控制</MenuItem>
                <MenuItem name="4-1" to="/explore">价格预测</MenuItem>
                <!-- <MenuItem name="4-2">农产品销售分析</MenuItem> -->
                <MenuItem name="4-3" to="/policy">最新政策</MenuItem>
              </MenuGroup>
              <MenuGroup title="统计报表">
                <!-- <MenuItem name="4-4">仓库使用</MenuItem> -->
                <MenuItem name="4-4" to="/salereport">销售报表</MenuItem>
                <!-- <MenuItem name="4-5">预算会计报表</MenuItem> -->
              </MenuGroup>
            </Submenu>
            <MenuItem name="5" to="/manage" v-if="manager">
              <Icon type="ios-construct" />
              综合设置
            </MenuItem>
          </div>
        </Menu>
      </div>

      <div id="section">
        <router-view></router-view>
      </div>

      <div id="footer">
        Copyright (c) 2020-2022 版权所有:信息1701 1710650105 金月
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  data: function () {
    return {
      name: "",
      roles: [
        "系统管理员",
        "农场主",
        "仓库管理员",
        "人事",
        "市场调查分析员",
        "销售",
      ],
      show: true,
      count: 0,
      manager: false,
      role: "",
    };
  },
  components: {},
  mounted: function () {
    if (sessionStorage.getItem("user")) {
      this.name = JSON.parse(sessionStorage.getItem("user")).name;
      this.role = JSON.parse(sessionStorage.getItem("user")).role;
      this.show = false;
      if (this.role === "系统管理员") {
        this.manager = true;
      }
    } else {
      this.name = "XXX";
    }
  },
  methods: {
    reroute: function () {
      // this.$router.push({name:'login'})
      window.location.href = "./logs.html";
    },
    jock: function () {
      this.count += 1;
      if (this.count == 1) {
        this.$Message.info("没事别点我");
      }
      if (this.count == 5) {
        this.$Message.info("你已经点了我" + this.count + "次了");
        // this.$Message.info("你蠢不蠢")
        // this.$Message.info("我让你点!!!!")
        // this.$Message.info("你猜猜我还有多个弹框要弹出来!!!!哈哈哈")
        // this.$Message.info("没错，我还有!!!!")
      }
      if (this.count == 20) {
        this.$Message.info("老板要炒你鱿鱼了！！！");
      }
      if (this.count == 50) {
        this.$Message.info("我已经报告给老板了!!!");
      }
    },
  },
};
</script>

<style scoped>
#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  border: 1px solid #d7dde4;
  background: #f5f7f9;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

@media screen and (min-width: 1200px) {
  #container {
    width: 1900px;
    height: 980px;
  }

  .layout-logo {
    width: 100px;
    height: 80px;
    /* background: #5b6270; */
    border-radius: 3px;
    float: left;
    position: relative;
    top: 0px;
    left: 10px;
  }

  .login {
    width: 40px;
    height: 15px;
    border-radius: 3px;
    position: absolute;
    right: 85px;
    top: 0px;
  }

  .login p {
    color: #f8f8f9;
    font-size: 15px;
  }

  .menuitems {
    position: relative;
    float: right;
    right: 160px;
  }
}

#header {
  width: 100%;
  height: 6.5%;
  padding-bottom: 2px;
}

#footer {
  width: 100%;
  height: 4%;
  text-align: center;
  font-size: 18px;
  background-color: #515a6e;
  font-family: "华文行楷", "Courier New", Courier, monospace;
  color: white;
  clear: both;
  border-top: 1px solid;
}

#section {
  pad: 2px;
  width: 100%;
  height: 88%;
}
</style>
